from aip import AipImageClassify #从aip包中导入AipImageClassify类名称
import json




""" 你的 APPID AK SK """
APP_ID = '21711527'
API_KEY = 'rGqoyOrwtG3oS1WLLUXAPvXB'
SECRET_KEY = 'BDzecMerT0ZAsnqm8gPBGZ4EzeWjva9s'


def detect_dish():
    # 创建AipImageClassify对象client
    client = AipImageClassify(APP_ID, API_KEY, SECRET_KEY)

    """ 读取图片 """
    def get_file_content(filePath):
        with open(filePath, 'rb') as fp:
            return fp.read()  #读文件内容二进制

    image = get_file_content('static/images/current.jpg')

    """ 如果有可选参数 """
    options = {}
    options["top_num"] = 3
    options["filter_threshold"] = "0.7"
    options["baike_num"] = 5

    """ 带参数调用菜品识别 """
    result = client.dishDetect(image, options)

    # print(type(result))
    # print(result)
    return  result

if  __name__ == '__main__':
    print(detect_dish())

